<?php
include_once "../header1.php";
?>

<?php
include_once ("$basedir"."/Login/databaseconnection.php");

if(!loggedin())
{
	require_once ("$basedir"."/index.php");
}
   
   else
   {
 if(isset($_POST['Search']))
	   {
	   $School_Id=$_POST['School_Id'];
	   $Exam_Name=$_POST['Exam_Name'];
	   $Year=$_POST['Year'];
	   }
	   if( $School_Id==" "||$Exam_Name==" "||$Year==" ")
	   {
		   $_SESSION['errorin1']="Not enough inputs!";
	   
	   }
	   
   ?>
  <?php

include_once "../header2.php";


?>
<?php
include_once "topmenu.php";
?>
<div class="left">
  
<div class="articles">
 <form action="#" method="POST">
 <table width="679" border="0">
      <tr>
        <td height="32" colspan="4" align="left" scope="row"><?php
		if(isset($_POST['Search']))
{
	if(isset($_SESSION['errorin1']))
	{
		echo $_SESSION['errorin1'];
		unset($_SESSION['errorin1']);
	}
}
		?></td>
        <td width="74" rowspan="3">Other Way:</td>
        <td width="233" rowspan="3"><table width="224" border="1">
          <tr>
            <td width="214"><input type="text" name="textfield" />
              
              <input name="SearchOther" align="middle" type="submit" value="Search" />
              </td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td width="100" rowspan="3" align="left" scope="row">Search by</td>
      <td width="101" height="30" align="left" scope="row">School Id:</td>
      <th width="12" align="left" scope="row">:-</th>
      <td width="133"><select name="School_Id" id="School_Id">
        <?php
	  
	  if(isset($_POST['Edit_This']))
	  {
	 echo '<option value="'.$School_Id.'">'.$School_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  
	  ?>
        <?php
	  $exa=mysql_query("SELECT DISTINCT(School_Id) FROM exam");
	  
  while($row=mysql_fetch_array($exa))
  {
	 $Sch_Id=$row['School_Id'];

	  echo '<option value="'.$Sch_Id.'">'.$Sch_Id.'</option>';
  }
  }
	  ?>
      </select></td>
      </tr>
    <tr>
      <td align="left" scope="row">Exam_Name:</td>
      <th width="12" align="left" scope="row">:-</th>
      <td><select name="Exam_Name" id="Exam_Name">
       <?php
	  
	  if(isset($_POST['Edit_This']))
	  {
	 echo '<option value="'.$Exam_Name.'">'.$Exam_Name.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  
	  ?>
        <?php
	  $exa=mysql_query("SELECT DISTINCT(Exam_Name) FROM exam");
	  
  while($row=mysql_fetch_array($exa))
  {
	 $Exa_Name=$row['Exam_Name'];

	  echo '<option value="'.$Exa_Name.'">'.$Exa_Name.'</option>';
  }
  }
	  ?>
      </select></td>
    </tr>
    <tr>
      <td height="30" align="left" scope="row">Year:</td>
      <th height="30" align="left" scope="row">:-</th>
      <th height="30" align="left" scope="row"><select name="Year" id="Year">
      <?php
	 if(isset($_POST['Edit_This']))
	  {
	 echo '<option value="'.$Year.'">'.$Year.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  
	  ?>
        <?php
	 $exa=mysql_query("SELECT DISTINCT(Year) FROM exam");
	  
  while($row=mysql_fetch_array($exa))
  {
  $Yea=$row['Year'];

	  echo '<option value="'.$Yea.'">'.$Yea.'</option>';
  }
  }
	 ?>
      </select></th>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <th height="41" colspan="2" align="left" scope="row"><a href="SearchExamSch.php">Reset</a>|
        <input name="Search" align="middle" type="submit" value="Search" /></th>
      <th height="41" colspan="2" align="left" scope="row"></th>
      <td colspan="2">&nbsp;</td>
    </tr>
  </table></form>
   <?php
   
	   if(isset($_POST['Search']))
	   {
	   $School_Id=$_POST['School_Id'];
	   $Exam_Name=$_POST['Exam_Name'];
	   $Year=$_POST['Year'];
	   }
	   
	   if( $School_Id!=" "&&$Exam_Name!=" "&&$year!=" ")
	   {
   $result=mysql_query("SELECT * FROM exam WHERE School_Id='$School_Id' AND Exam_Name='$Exam_Name' AND Year='$Year'");
	    echo '<table width="458" border="0">';
 while($row=mysql_fetch_array($result))
  {
    
	 $s_name=$row['School_Id'];
$Exam_Name['Exam_Name'];
$yea=$row['Year'];
$No_Of_Sat =$row['No_Of_Sat_Students'];
$No_Of_Passed =$row['No_Of_Passed_Students'];
     
      echo '<tr>';
        echo '<th width="200" height="44" scope="row">';
		echo "School Id:";
		echo '</th>';
        echo '<td width="144">';
		echo $s_name;
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Exam Name:";
		echo '</th>';
        echo '<td>';
		echo $Exam_Name;
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Year :";
		echo '</th>';
        echo '<td>';
		echo $yea;
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Number Of Sat_Student :"; 
		echo '</th>';
       echo '<td>';
	  
	  echo $No_Of_Sat;
	   echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Number Of Passed_Students:"; 
		echo '</th>';
        echo '<td>';
		echo $No_Of_Passed ;
            
        echo '</td>';
      echo '</tr>';
       
  }
    echo '</table>';
	}
	
   ?>
 
</div>
</div>
<div class="rightmenu"> 
<?php
include_once "menu.php";
?>
<?php
include_once "../footer.php";
?>
<?php
}
	  
	   ?>
</body>
</html>